using Digitalmes.Domain.Entities.Mes.Processes;

namespace Digitalmes.Application.Mes.Processes.StepStandards.Queries;

/// <summary>
/// 工艺标准查询命令。
/// </summary>
public sealed record GetStepStandardListQuery(long StepId, long StepTaskId) : IRequest<IResult<List<ProcStepStandardDto>>>;

internal sealed class GetStepStandardListQueryHandler(IRepository<ProcStepStandard> repo) : IRequestHandler<GetStepStandardListQuery, IResult<List<ProcStepStandardDto>>>
{
    public async Task<IResult<List<ProcStepStandardDto>>> Handle(GetStepStandardListQuery request, CancellationToken cancellationToken)
    {
        var items = await repo.GetListAsync(m => m.StepId == request.StepId && m.StepTaskId == request.StepTaskId, cancellationToken);
        return Result.From(items.Adapt<List<ProcStepStandardDto>>());
    }
}
